package org.UDPchatRoomDemo;

import java.io.IOException;
import java.net.*;
import java.util.Scanner;

public class sendMessageDemo {
    public static void main(String[] args) throws IOException {
        DatagramSocket datagramSocket=new DatagramSocket();
        Scanner sc=new Scanner(System.in);
        InetAddress byName = InetAddress.getByName("127.0.0.1");
        while (true) {
            String speak =sc.nextLine();
            byte[] data = speak.getBytes();

            DatagramPacket datagramPacket=new DatagramPacket(data,data.length,byName,10086);
            datagramSocket.send(datagramPacket);
            if (speak.equals("bye")){
                break;
            }
        }
        datagramSocket.close();
    }
}
